package modelo;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
@Named("eMFactory")
@ApplicationScoped
public class EMFactory {
	private EntityManagerFactory emf; 
	@Produces @RequestScoped
	public EntityManager produzEntityManager() {
		if (emf==null) {
			emf = Persistence.createEntityManagerFactory("campeonato");
		}
		EntityManager em = emf.createEntityManager();
		em.getTransaction().begin();
		return em;
	}
}